<?php
    include APPPATH.'/libraries/AdminAccessAssertion.php';
	function init_roles() {
		$acl = new Zend_Acl();        
		//определяем ресурсы/контроллеры
		$acl->add(new Zend_Acl_Resource('page'));
		$acl->add(new Zend_Acl_Resource('category'));
		$acl->add(new Zend_Acl_Resource('member'));
        $acl->add(new Zend_Acl_Resource('cart'));
        $acl->add(new Zend_Acl_Resource('search'));		
		
		$acl->add(new Zend_Acl_Resource('dashboard'));
		$acl->add(new Zend_Acl_Resource('table'));

		// определяем роли
		$guest = new Zend_Acl_Role('guest');
		$acl->addRole($guest);
		$acl->addRole(new Zend_Acl_Role('client'), 'guest');
		$acl->addRole(new Zend_Acl_Role('manager'), 'client');
		$acl->addRole(new Zend_Acl_Role('administrator'));

		//определяем доступ
		$acl->allow('guest', array('category', 'page', 'search'));
		$acl->allow('guest', 'member', array('login', 'register'));
		
		$acl->allow('client', 'member', array('logout', 'orders'));
		$acl->allow('client', 'cart');
		
		$acl->allow('manager', 'table', array(), new AdminAccessAssertion());
		$acl->allow('manager', 'dashboard', array(), new AdminAccessAssertion());
		
		$acl->allow('administrator', array(), array(), new AdminAccessAssertion());

		return $acl;
	}
?>